package ${conf.basePackage}.${table.camelName}.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ${conf.basePackage}.${table.camelName}.dao.${table.className}DAO;
import ${conf.basePackage}.${table.camelName}.model.${table.className};
import ${conf.basePackage}.${table.camelName}.service.${table.className}Service;

/**
 * ${table.comment}
 * @author ${conf.author}
 * @version ${conf.version}
 * @since ${conf.createDate}
 */
@Service("${table.camelName}Service")
public class ${table.className}ServiceImpl implements ${table.className}Service {

	@Autowired
	private ${table.className}DAO ${table.camelName}DAO;

	@Override
	public List<${table.className}> query(Map<String, Object> params) {
		return ${table.camelName}DAO.selectByParams(params);
	}

	@Override
	public ${table.className} findById(long id) {
		return ${table.camelName}DAO.selectByPrimaryKey(id);
	}

	@Override
	public List<${table.className}> queryByIds(List<Long> ids) {
		Map<String, Object> params = new HashMap<>();
		params.put("ids", ids);
		return ${table.camelName}DAO.selectByParams(params);
	}

	@Override
	public List<${table.className}> page(Map<String, Object> params, int offset, int size) {
		params.put("offset", offset);
		params.put("size", size);
		return ${table.camelName}DAO.selectByParams(params);
	}

    @Override
    public int count(Map<String, Object> params) {
		return ${table.camelName}DAO.countByParams(params);
    }

	@Override
	public ${table.className} findFirst(Map<String, Object> params) {
		return ${table.camelName}DAO.selectByParams(params).get(0);
	}

	@Override
	public int save(${table.className} ${table.camelName}) {
		return ${table.camelName}DAO.insert(${table.camelName});
	}

	@Override
	public int batchSave(List<${table.className}> ${table.camelName}List) {
		return ${table.camelName}DAO.insertBatch(${table.camelName}List);
	}

    @Override
    public int saveSelective(${table.className} ${table.camelName}) {
    	return ${table.camelName}DAO.insertSelective(${table.camelName});
    }

	@Override
	public int modify(${table.className} ${table.camelName}) {
		return ${table.camelName}DAO.updateByPrimaryKey(${table.camelName});
	}

    @Override
    public int modifySelective(${table.className} ${table.camelName}) {
    	return ${table.camelName}DAO.updateByPrimaryKeySelective(${table.camelName});
    }

	@Override
	public int remove(long id) {
		return ${table.camelName}DAO.deleteByPrimaryKey(id);
	}

	@Override
	public int batchRemove(List<Long> ids) {
		return ${table.camelName}DAO.deleteBatchByPrimaryKey(ids);
	}
}